<!-- include tpl=head_lay nopadding=true -->
<style type="text/css">
.checkbox {
	position:absolute;
	padding:5px 8px 2px 8px;
	background:#fff;
	top:1px;
	left:1px;
	z-index:1;
	box-shadow:2px 2px 2px rgba(0,0,0,0.5);
	border:1px solid #ccc;
}
.layui-card-header .layui-icon{
	position:static;
}
</style>
<script type="text/javascript">
function phpok_input(val)
{
	$(".piclist li").removeClass("hover");
	var obj = $.dialog.opener;
	obj.obj_{$id}.open_action(val);
	var content = obj.$("#{$id}").val();
	if(content){
		var list = content.split(",");
		for(var i in list){
			$("#attr_"+list[i]).addClass("hover");
		}
	}
	if(is_more == false){
		$.dialog.close();
	}
}
function update_select(val)
{
	if(val == 'start_date' || val == 'stop_date'){
		$("#keywords").focus(function(){
			laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})
		});
	} else {
		$("#keywords").unbind('focus').click(function(){
			$(this).select();
		});
	}
}
function check_search()
{
	var cate_id = $("#top_cate_id").val();
	var keywords = $("#keywords").val();
	if(!cate_id && !keywords){
		$.dialog.alert('请选择要搜索的项');
		return false;
	}
	return true;
}
function add_input(id)
{
	var obj = $.dialog.opener;
	obj.$("#{$id}").val(id);
	obj.$.phpokform.upload_showhtml('{$id}',false);
	$.dialog.close();
}
function add_select(id){
	var obj = $.dialog.opener;
	var old = obj.$("#{$id}").val();
	if($("#addfile_"+id).prop("checked")){
		var act = 'add';
	}else{
		var act = 'delete';
	}
	if(act == 'add'){
		var info = (old && old != 'undefined') ? old+","+id : id;
		var list = info.split(',');
		list = $.unique(list);
		info = list.join(",");
		obj.$("#{$id}").val(info);
		obj.$.phpokform.upload_showhtml('{$id}',true);
		return true;
	}
	if(id == old){
		obj.$("#{$id}").val('');
		obj.obj_{$id}.showhtml();
		return true;
	}
	var list = old.split(",");
	var nlist = new Array();
	var m = 0;
	for(var i in list){
		if(list[i] != id){
			nlist[m] = list[i];
			m++;
		}
	}
	old = nlist.join(',');
	obj.$("#{$id}").val(old);
	obj.$.phpokform.upload_showhtml('{$id}',true);
	return true;
}
</script>
<!-- if $session.admin_id && $sys.app_id == 'admin' -->
<link rel="stylesheet" type="text/css" href="{#js#}/webuploader/webuploader.css" />
<script type="text/javascript" src="{#js#}/webuploader/webuploader.min.js"></script>
<script type="text/javascript" src="{#js#}/webuploader/admin.upload.js"></script>
<script type="text/javascript">
function cate_change()
{
	val = $("#upload_cate_id").val();
	if(!val){
		$.dialog.alert('请选择要存储的目标分类');
		return false;
	}
	var url = '{$formurl}&cate_id='+val;
	$.phpok.go(url);
}
</script>
<!-- /if -->


<div class="layui-card">
	<div class="layui-card-header layuiadmin-card-header-auto">
		<form method="post" action="{$formurl}" class="layui-form" id="post_save" onsubmit="return check_search()">
		<div class="layui-row layui-col-space10 ">
			<div class="layui-col-md2">
				<select name="day">
					<option value="">不限</option>
					<!-- loop from=$daylist key=$key value=$value id=$tmpid -->
					<option value="{$value.value}"{if $value.value == $day} selected{/if}>{$value.title}</option>
					<!-- /loop -->
				</select>
			</div>
			<div class="layui-col-md2">
				<select name="cate_id" id="top_cate_id">
					<option value="">全部分类…</option>
					<!-- loop from=$catelist key=$key value=$value id=$tmpid -->
					<option value="{$value.id}"{if $value.id == $cate_id} selected{/if}>{$value.title}</option>
					<!-- /loop -->
				</select>
			</div>
			<div class="layui-col-md2">
				<input type="text" name="keywords" id="keywords" value="{$keywords}" class="layui-input" />
			</div>
			<div class="layui-col-md2">
				<div class="layui-btn-group" style="margin-top:-6px;">
					<input type="submit" value="{lang搜索}" class="layui-btn layui-btn-sm" />
					<input type="button" value="{lang刷新}" class="layui-btn layui-btn-sm" onclick="$.phpok.reload()" />
				</div>
			</div>
			<!-- if $session.admin_id && $sys.app_id == 'admin' -->
			<div class="layui-col-md2">
				{$upload_buttons}
			</div>
			<!-- /if -->
		</div>
		</form>
	</div>
	<div class="layui-card-body">
		<div class="layui-row layui-col-space10 filelist" id="filelists">
			<!-- loop from=$rslist key=$key value=$value id=$tmpid -->
			<div class="layui-col-xs6 layui-col-sm4 layui-col-md3 layui-col-lg2">
				<div class="layui-card" lay-tips="{lang名称：}{$value.title}<br/>{lang添加：}{func date 'Y-m-d H:i:s' $value.addtime}{if $value.attr && $value.attr.width && $value.attr.height}<br/>{lang属性：}{$value.attr.width}x{$value.attr.height}{/if}">
					<div class="layui-card-body"{if !$multiple} onclick="add_input('{$value.id}')"{/if}>
						<label>
							<!-- if $multiple -->
							<div class="checkbox">
								<input type="checkbox" name="addfile[]" onclick="add_select('{$value.id}')" id="addfile_{$value.id}" value="{$value.id}" />
							</div>
							<!-- /if -->
							<img src="{$value.ico}"  style="width:100%;" />
						</label>
					</div>
				</div>
			</div>
			<!-- /loop -->
		</div>
		<!-- include tpl=pagelist -->	
	</div>
</div>

<script type="text/javascript">
$(document).ready(function(){
	var obj = $.dialog.opener;
	var old = obj.$("#{$id}").val();
	if(old && old != 'undefined'){
		var list = old.split(',');
		for(var i in list){
			$("#addfile_"+list[i]).prop('checked',true);
		}
	}
});
</script>
<!-- include tpl=foot_lay is_open=true -->